/*
 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> et al.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifndef __MTD_ABI_H__
#define __MTD_ABI_H__

#include <types.h>

/**
 * MTD operation modes
 *
 * @MTD_OPS_PLACE_OOB:  OOB data are placed at the given offset (default)
 * @MTD_OPS_AUTO_OOB:   OOB data are automatically placed at the free areas
 *          which are defined by the internal ecclayout
 * @MTD_OPS_RAW:    data are transferred as-is, with no error correction;
 *          this mode implies %MTD_OPS_PLACE_OOB
 *
 * These modes can be passed to ioctl(MEMWRITE) and are also used internally.
 * See notes on "MTD file modes" for discussion on %MTD_OPS_RAW vs.
 * %MTD_FILE_MODE_RAW.
 */
enum {
    MTD_OPS_PLACE_OOB = 0,
    MTD_OPS_AUTO_OOB = 1,
    MTD_OPS_RAW = 2,
};

#define MTD_ABSENT      0
#define MTD_RAM         1
#define MTD_ROM         2
#define MTD_NORFLASH        3
#define MTD_NANDFLASH       4
#define MTD_DATAFLASH       6
#define MTD_UBIVOLUME       7
#define MTD_MLCNANDFLASH    8

#define MTD_WRITEABLE       0x400   /* Device is writeable */
#define MTD_BIT_WRITEABLE   0x800   /* Single bits can be flipped */
#define MTD_NO_ERASE        0x1000  /* No erase necessary */
#define MTD_POWERUP_LOCK    0x2000  /* Always locked after reset */

/* Some common devices / combinations of capabilities */
#define MTD_CAP_ROM     0
#define MTD_CAP_RAM     (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
#define MTD_CAP_NORFLASH    (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
#define MTD_CAP_NANDFLASH   (MTD_WRITEABLE)

struct nand_oobfree {
    __u32 offset;
    __u32 length;
};

/**     
 * struct mtd_ecc_stats - error correction stats
 *  
 * @corrected:  number of corrected bits
 * @failed: number of uncorrectable errors
 * @badblocks:  number of bad blocks in this partition
 * @bbtblocks:  number of blocks reserved for bad block tables
 */ 
struct mtd_ecc_stats {
    __u32 corrected;
    __u32 failed;
    __u32 badblocks;
#ifndef __MBOOT__
    __u32 bbtblocks;
#endif
};

#endif /* __MTD_ABI_H__ */

